package com.platform.web.controller.base;

import com.platform.base.domain.BaseEquip;
import com.platform.base.service.IBaseEquipService;
import com.platform.common.core.controller.BaseController;
import com.platform.common.core.page.TableDataInfo;
import com.platform.common.utils.redis.RedisUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * 住户信息Controller
 * 
 * @author wangqi
 * @date 2020-09-24
 */
@Controller
@RequestMapping("/base/location/equip")
public class BaseEquipController extends BaseController
{
    private String prefix = "base/location/equip";

    @Autowired
    private IBaseEquipService baseEquipService;

    @Autowired
    private RedisUtil redisUtil;

    @RequiresPermissions("base:location:equip:view")
    @GetMapping(value = { "", "/{locationId}" })
    public String location(@PathVariable(value = "locationId", required = false) String locationId, ModelMap mmap)
    {

        Calendar ca = Calendar.getInstance();
        ca.setTime(new Date());
        ca.add(Calendar.MONTH, -1);
        Date resultDate = ca.getTime();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        mmap.put("beginTime", dateFormat.format(resultDate));
        mmap.put("endTime", dateFormat.format(new Date()));
        if(locationId == null){
            mmap.put("locationId",	"1");}
        else{mmap.put("locationId",locationId	);}


        return prefix + "/location";
    }




    /**
     * 查询住户信息列表
     */
    @RequiresPermissions("base:location:equip:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BaseEquip baseEquip)
    {
        startPage();
        List<BaseEquip> list = baseEquipService.selectBaseEquipList(baseEquip);
        return getDataTable(list);
    }



   

    
}
